home *** CD-ROM | disk | FTP | other *** search
- <!--- This example shows the use of ToBinary and ToBase64 --->
- <html>
- <head>
- <title>
- ToBase64 Example
- </title>
- </head>
-
- <BASEFONT FACE="Arial, Helvetica" SIZE=2>
- <BODY bgcolor="#FFFFD5">
-
- <h3>ToBase64 Example</h3>
-
- <!----------------------------------------------------------------------
- Initialize data.
- ----------------------------------------------------------------------->
- <CFSet charData ="">
- <!----------------------------------------------------------------------
- Create a string of all ASCII characters (32-255) and concatenate them together.
- ----------------------------------------------------------------------->
- <CFLoop index="data" from="32" to="255">
- <CFSet ch=chr(data)>
- <CFSet charData=charData & ch>
- </CFLoop>
- <p>
- The following string is the concatenation of all characters (32 to 255) from the ASCII table.<br>
- <cfoutput>#charData#</cfoutput>
- </p>
- <!----------------------------------------------------------------------
- Create a Base 64 representation of this string.
- ----------------------------------------------------------------------->
- <cfset data64=toBase64(charData)>
-
- <!----------------------------------------------------------------------
- Convert string to binary.
- ----------------------------------------------------------------------->
- <CFSet binaryData=toBinary(data64)>
- <!----------------------------------------------------------------------
- Convert binary back to Base 64.
- ----------------------------------------------------------------------->
- <CFSet another64=toBase64(binaryData)>
- <!----------------------------------------------------------------------
- Compare another64 with data64 to ensure that they are equal.
- ----------------------------------------------------------------------->
- <CFIf another64 eq data64>
- <h3>Base 64 representations are identical.</h3>
- <CFElse>
- <h3>Conversion error.</h3>
- </CFIf>
- </body>
- </html>
-